/**
 * @(#)TaskManager.java        1.0 2/28/12
 * 
 * Copyright (c) 2012 public static droid main
 * Georgia Institute of Technology, Atlanta, GA
 * All rights reserved.
 */
package edu.gatech.oad.publicstaticdroidmain.taskmanager.model;

import java.util.Date;

/**
 * A facade that controls the entire TaskManager application.  This
 * class will be used by the UI to interact with the TaskManager,
 * ensuring that the UI is not exposed to any of the model's internal
 * objects and data.  Most of its methods are pass-through methods to 
 * UserAccount.
 * 
 * @version 1.0 2/28/12
 * @author Raheel Merali
 *
 */
public class TaskManager {
    
    private UserAccount account;
    
    /**
     * Constructs a new TaskManager that will operate on the specified
     * UserAccount.
     * 
     * @param account UserAccount with the current user's information
     */
    public TaskManager(UserAccount account) {
	this.account = account;
    }
    
    /**
     * Returns the username of the UserAccount being controlled by the TaskManager.
     * 
     * @return the username of the account being controlled by the TaskManager.
     */
    public String getUsername() {
	return account.getUsername();
    }
    
    /**
     * Returns the real name of the person whose UserAccount is being controlled 
     * by this TaskManager.
     * 
     * @return the real name of the person whose UserAccount is being controlled
     * 		by this TaskManager
     */
    public String getRealName() {
	return account.getRealName();
    }
    
    /**
     * Returns the e-mail address of the person whose UserAccount is being 
     * controlled by this TaskManager.
     * 
     * @return the e-mail address of the person whose UserAccount is being 
     * controlled by this TaskManager
     */
    public String getEmailAddress() {
	return account.getEmailAddress();
    }
    
    /**
     * Sets the username of the account being controlled by this TaskManager.
     * 
     * @param newUsername the new username
     */
    public void setUsername(String newUsername) {
	account.setUsername(newUsername);
    }
    
    /**
     * Sets the password for the account being controlled by this TaskManager.
     * 
     * @param oldPassword the UserAccount's current password
     * @param newPassword the new password to set
     */
    public void setPassword(String oldPassword, String newPassword) {
	account.setPassword(oldPassword, newPassword);
    }
    
    /**
     * Sets the real name of the account being controlled by this TaskManager.
     * 
     * @param newRealName the new real name
     */
    public void setRealName(String newRealName) {
	account.setRealName(newRealName);
    }
    
    /**
     * Sets the e-mail address of the account being controlled by this TaskManager.
     * 
     * @param newEmailAddress the new email address
     */
    public void setEmailAddress(String newEmailAddress) {
	account.setEmailAddress(newEmailAddress);
    }
    
    /**
     * Adds the specified category to this TaskManager's UserAccount.
     * 
     * @param category the name of the category to add
     * @return true if the category was added successfully; false if the
     * 		category already exists
     */
    public boolean addCategory(String category) {
	return account.addCategory(category);
    }
    
    /**
     * Changes the name of the specified category to the specified new
     * name.  If the new name is already taken by another category,
     * the Tasks in the old category will be moved to the new
     * category.
     * 
     * @param oldName the name of the category to edit
     * @param newName the new name of the category
     * @return true if the category's name was successfully changed; false
     * 		if the category does not exist
     */
    public boolean editCategoryName(String oldName, String newName) {
	return account.editCategoryName(oldName, newName);
    }
    
    /**
     * Removes the specified category from this TaskManager's UserAccount
     * if it exists.
     * 
     * @param category the name of the category to remove
     * @return true if the category was successfully removed; false if the
     * 		specified category does not exist
     */
    public boolean removeCategory(String category, String replacement) {
	return account.removeCategory(category, replacement);
    }
    
    /**
     * Returns the Tasks in the specified category in this TaskManager's
     * UserAccount.
     * 
     * @param category the category of Tasks to retrieve
     * @return an array containing the Tasks in the specified category; null
     * 		if the specified category does not exist
     */
    public Task[] getTasksInCategory(String category) {
	return account.getTasksInCategory(category);
    }
    
    /**
     * Returns the Tasks with the specified completion status in this 
     * TaskManager's UserAccount.
     * 
     * @param completionStatus the completion status of the Tasks to
     * 		retrieve
     * @return an array containing the Tasks in this account with the
     * 		specified completion status
     */
    public Task[] getTasksWithCompletionStatus(boolean completionStatus) {
	return account.getTasksWithCompletionStatus(completionStatus);
    }
    
    /**
     * Returns the Tasks whose due dates on or after the specified Date
     * in this TaskManager's UserAccount.
     * 
     * @param date the dividing Date
     * @return an array of Tasks whose due dates are on or after the
     * 		specified date
     */
    public Task[] getTasksAfterDate(Date date) {
	return account.getTasksAfterDate(date);
    }
    
    /**
     * Returns the names of the categories in this TaskManager's UserAccount.
     * 
     * @return an array containing the names of the categories in
     * 		this TaskManager's UserAccount
     */
    public String[] getCategories() {
	return account.getCategories();
    }
    
    /**
     * Adds the specified Task to this UserAccount if one with the
     * same ID does not already exist.
     * 
     * @param task the Task to add
     * @return true if the Task was successfully added; false if a Task with
     * 		the same ID as the specified Task already exists in the account
     */
    public boolean addTask(Task task) {
	return account.addTask(task);
    }
    
    /**
     * Updates the specified Task's information in the UserAccount.  If
     * you change the information in a Task object, call this method to save
     * the changes in this TaskManager's UserAccount.
     * 
     * @param task the Task to update
     * @return true if the specified Task was successfully updated; false if
     * 		the specified Task does not exist in this TaskManager's
     * 		UserAccount
     */
    public boolean updateTask(Task task) {
	return account.updateTask(task);
    }
    
    /**
     * Removes the specified Task from this TaskManager's UserAccount if
     * it exists.
     * 
     * @param task the Task to remove
     * @return true if the Task was successfully removed; false if the Task
     * 		does not exist in this TaskManager's UserAccount
     */
    public boolean removeTask(Task task) {
	return account.removeTask(task);
    }
    
    /**
     * Returns the Task object in this TaskManager's UserAccount with the
     * specified ID.
     * 
     * @param id the ID of the Task to retrieve
     * @return the Task object in this TaskManager's UserAccount with the
     * 		specified ID; null if a Task with the specified ID does
     * 		not exist in this TaskManager's UserAccount
     */
    public Task getTask(long id) {
	return account.getTask(id);
    }
    
    /**
     * Returns all of the Tasks in this TaskManager's UserAccount.
     * 
     * @return an array containing all of the Tasks in this TaskManager's
     * 		UserAccount.
     */
    public Task[] getAllTasks() {
	return account.getAllTasks();
    }

}